<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>吐槽</title>
    <!--百度统计-->
    <script src="/blog/js/statistics.js"></script>
    <!--layUI的css-->
    <link rel="stylesheet" href="/layui/css/layui.css">
    <!--layUI的js-->
    <script src="/layui/layui.js"></script>
    <!--兔小巢-->
    <script src="/lib/tucao/tucao.js"></script>
</head>
<body>

</body>
</html>
<script>
    let $ = layui.$;

    /*吐槽的函数*/
    function tucao() {
        let layer = layui.layer;
        let token = localStorage.getItem("token");
        if (token == null) {
            layer.alert("登录之后再吐槽哦", {icon: 3}, function (index) {
                window.close();
            });
            return false;
        }
        $.get("/user/myInfo", {"token": token}, function (result) {
            if (result.code === 200) {
                let data = {
                    // nickname,avatar,openid 必填
                    "nickname": result.data.username,
                    "avatar": result.data.headPortraitUrl,
                    "openid": result.data.id
                }
                let productId = 353843;
                Tucao.request(productId, data);
            } else if (result.code === 401) {
                localStorage.removeItem("token");
                sessionStorage.clear();
                layer.msg(result.msg, {icon: 5});
            } else
                layer.msg(result.msg, {icon: 5});
        })
    }

    // 调用
    tucao();
</script>